package cn.iocoder.yudao.module.shop.favorite.service;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.pojo.vo.UserSimpleVO;
import cn.iocoder.yudao.framework.business.basic.service.impl.MemberScopeService;
import cn.iocoder.yudao.module.api.member.user.MemberUserApi;
import cn.iocoder.yudao.module.shop.favorite.dal.dataobject.ShopFavoriteDO;
import cn.iocoder.yudao.module.shop.favorite.dal.mysql.ShopFavoriteMapper;
import cn.iocoder.yudao.module.shop.favorite.vo.AdminShopFavoriteQueryDTO;
import cn.iocoder.yudao.module.shop.favorite.vo.AdminShopFavoriteVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.Collection;
import java.util.Map;

/**
 * 店铺收藏 Service 实现类
 *
 * @author 山野羡民
 */
@Service
@Validated
public class AdminShopFavoriteServiceImpl extends MemberScopeService<ShopFavoriteDO, AdminShopFavoriteVO, AdminShopFavoriteQueryDTO> implements AdminShopFavoriteService {
    @Resource
    private ShopFavoriteMapper shopFavoriteMapper;

    @Resource
    private MemberUserApi memberUserApi;

    @Override
    protected ShopFavoriteMapper getInjectedMapper() {
        return shopFavoriteMapper;
    }

    @Nonnull
    @Override
    protected CoreQueryWrapper<ShopFavoriteDO> buildQueryWrapper(AdminShopFavoriteQueryDTO param) {
        CoreQueryWrapper<ShopFavoriteDO> wrapper = super.buildQueryWrapper(param);
        wrapper.eq("user_id", param.getUserId());
        wrapper.eq("recycled", false);
        return wrapper;
    }

    @Nonnull
    @Override
    protected Map<Long, UserSimpleVO> getUserSimpleMap(Collection<Long> userIds) {
        return memberUserApi.getUserSimpleMap(userIds);
    }

}
